package cn.wolfcode.luowowo.website.controller;

import cn.wolfcode.luowowo.acticle.query.TravelQuery;
import cn.wolfcode.luowowo.acticle.service.IStrategyCommendService;
import cn.wolfcode.luowowo.acticle.service.ITravelCommendService;
import cn.wolfcode.luowowo.acticle.service.ITravelService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {

    @Reference
    private ITravelCommendService travelCommendService;

    @Reference
    private ITravelService travelService;

    @Reference
    private IStrategyCommendService strategyCommendService;


    @RequestMapping("")
    public String index(Model m){
        //tcs  游记推荐
        m.addAttribute("tcs",travelCommendService.getHotTravelCommendTopN(5));

        //scs 攻略推荐
        m.addAttribute("scs",strategyCommendService.getHotStrategyCommendTopN(1));
        return "index/index";
    }

    @RequestMapping("/index/travelPage")
    public String travelPage(Model m, @ModelAttribute("qo")TravelQuery qo){
        m.addAttribute("pageInfo",travelService.query(qo));
        return "index/travelPageTpl";
    }

}

